<%@ Application Language="C#" %>

<script runat="server">
    public static System.Timers.Timer WorldTimer;
    
    void Application_Start(object sender, EventArgs e) 
    {
        IrcManager.GoIRC();
        // Code that runs on application startup
        WorldTimer = new System.Timers.Timer();
        WorldTimer.Interval = 1000;
        // Hook up the Elapsed event for the timer.
        WorldTimer.Elapsed += new System.Timers.ElapsedEventHandler(GameWorld.Tick);
        WorldTimer.Elapsed += new System.Timers.ElapsedEventHandler(WorldTick);
        WorldTimer.Enabled = true;
    }

    // Specify what you want to happen when the Elapsed event is 
    // raised.
    public static void WorldTick(object source, System.Timers.ElapsedEventArgs e)
    {
        
        //((GameWorld)this.Application["World"]).Tick();
        System.Diagnostics.Debug.WriteLine("WorldTick: " + GameWorld.WorldTicks.ToString());
        
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started
        // We add the new player to the game world
        Session["EntityPlayer"] = GameWorld.AddPlayer(Session.SessionID);   
    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }
       
</script>
